#ifndef GUMSTIX_H_
#define GUMSTIX_H_

// Structures for Gumstix communication
typedef struct
{
	unsigned int SOP;			// Start of packet, fill this with something like 0xDEAD
	unsigned int voltageLevel;	// Voltage level signal
	unsigned int magx;			// Magnetometer X axis value
	unsigned int magy;			// Magnetometer Y axis value
	unsigned int magz;			// Magnetometer Z axis value
	unsigned int gyrox;			// Gyro X-Y X axis value
	unsigned int gyroy;			// Gyro X-Y Y axis value
	unsigned int gyroz;			// Gyro Z Z axis value
	unsigned int gyroxyref;		// Gyro X-Y voltage reference value
	unsigned int gyroztemp;		// Gyro Z temperature measurement
	unsigned int accelx;		// Accelerometer X value
	unsigned int accely;		// Accelerometer Y value
	unsigned int accelz;		// Accelerometer Z value
	unsigned int altsonar;		// Altitude sonar reading
	unsigned int motor1;		// Motor 1 level (top blade motor)
	unsigned int motor2;		// Motor 2 level (bottom blade motor)
	unsigned int servo1;		// Servo 1 level (roll servo)
	unsigned int servo2;		// Servp 2 level (pitch servo)
	unsigned int EOP;			// End of packet, fill this with something like 0xBEEF
}SensorInfo;

typedef struct
{
	unsigned char buffer[sizeof(SensorInfo)];	// Actual Buffer (size of one packet) for input - this length may want to change in future
	unsigned char *start;						// Pointer To Start Element
	unsigned char *end;							// Pointer To End Element
	unsigned int length;						// Length Of Buffer
}GumstixInputBuffer;

typedef struct
{
	unsigned char buffer[sizeof(SensorInfo)];	// Actual Buffer (size of one packet) for output packet
	unsigned char *start;						// Pointer To Start Element
	unsigned char *end;							// Pointer To End Element
	unsigned int length;						// Length Of Buffer
}GumstixOutputBuffer;

// States for gumstix synchronization routine state machine (start at init)
typedef enum
{
	GUMSTIX_STATE_INIT,
	GUMSTIX_STATE_READY,
	GUMSTIX_STATE_SYNCED
}GumstixSyncState;

// Public functions
void GumstixInit(void);
void GumstixTXInfo(SensorInfo*);
unsigned char GumstixIsReady(void);
void GumstixSendSync(void);
unsigned char GumstixRxSync(void);

#endif /*GUMSTIX_H_*/
